﻿using System.Linq;

namespace Cfg.ValidationAttributes
{
    public abstract class CfgFinalizedStringValueValidatorBaseAttribute : CfgValidatorBaseAttribute
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="finalizedStringValue"></param>
        protected abstract void Validate(string finalizedStringValue);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="finalizedStringValue"></param>
        /// <param name="context"></param>
        public virtual void Validate(string finalizedStringValue, string context)
        {
            var apply = Contexts == null || context == null || Contexts.Contains(context);
            if (apply)
                Validate(finalizedStringValue);
        }
    }
}
